package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-13 01:58
 */
public class MinDiffInBST {

    int min = 100001, pre = -1;

    public int minDiffInBST(TreeNode root) {
        if (root == null) return 0;
        minDiffInBST(root.left);
        if (pre < 0) {
            pre = root.val;
        }else {
           min=  Math.min(root.val- pre,min);
           pre=root.val;
        }
        minDiffInBST(root.right);
        return min;
    }
}
